package server

import (
	"6-17yk/common/model/mysql"
	"6-17yk/common/proto/user"
	"errors"
)

func InstitutionList(req *user.InstitutionListReq) (*user.InstitutionListResp, error) {
	list, err := mysql.GetInstitutionList(int(req.Page), int(req.Size), req.InstitutionName)
	if err != nil {
		return nil, errors.New("查询失败")
	}
	var lists []*user.InstitutionList
	for _, institution := range list {
		lists = append(lists, &user.InstitutionList{
			DoctorTeamId:        int64(institution.DoctorTeamId),
			InstitutionName:     institution.InstitutionName,
			InstitutionInternal: institution.InstitutionInternal,
			InstitutionPhone:    institution.InstitutionPhone,
			InstitutionImage:    institution.InstitutionImage,
		})
	}
	return &user.InstitutionListResp{List: lists}, nil
}
